<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      canvas {
        background-color: rgb(28, 236, 243);
        display: block;
        margin: 0 auto;
      }
    </style>
  </head>
  <body>
    <script>
      const canvas = document.createElement("canvas");
      canvas.width = 600;
      canvas.height = 400;
      document.body.append(canvas);
      const context = canvas.getContext("2d");

      context.strokeStyle = "red";
      // context.moveTo(200, 0);
      // context.lineTo(200, 400);
      context.setLineDash([4, 4]);
      // context.stroke();

      let g = context.createLinearGradient(0, 0, 400, 0);
      g.addColorStop(0, "red");
      g.addColorStop(0.25, "orange");
      g.addColorStop(0.5, "green");
      g.addColorStop(0.75, "orange");
      g.addColorStop(1, "black");

      context.fillStyle = g;

      // context.direction = "ltr";
      // context.direction = "rtl";
      // context.font = "40px Arial";
      // context.textAlign = "left";
      // context.textAlign = "right";
      // context.textAlign = "center";
      // context.textAlign = "end";

      // context.fillText("left", 200, 50);

      // context.textAlign = "right";
      // context.fillText("right", 200, 100);

      // context.textAlign = "center";
      // context.fillText("center", 200, 150);

      // context.textAlign = "start";
      // context.fillText("start", 200, 200);

      // context.textAlign = "end";
      // context.fillText("end", 200, 250);

      const baselines = [
        "top",
        "hanging",
        "middle",
        "alphabetic",
        "ideographic",
        "bottom",
      ];
      context.font = "36px serif";

      baselines.forEach((baseline, index) => {
        context.textBaseline = baseline;
        const y = 75 + index * 75;
        context.beginPath();
        context.moveTo(0, y + 0.5);
        context.lineTo(550, y + 0.5);
        context.stroke();
        context.fillText(`Abcdefghijklmnop (${baseline})`, 0, y);
      });
    </script>
  </body>
</html>
